import {createRouter,createWebHistory} from "vue-router";
import type {RouteRecordRaw} from 'vue-router'
import Layout from '@/layout/Index.vue'    // 这里配置layout/Index.vue为主页，以后访问localhost:8081/home就是主页了

const routes: Array<RouteRecordRaw> = [
    // 首页路由
    {
        path: '/',
        component: Layout,
        redirect: '/dashboard',
        children: [
            {
                path: '/dashboard',
                component: () => import('@/views/dashboard/Index.vue'),
                name: 'dashboard',
                meta: {
                    title: '首页',
                    icon: '#icondashboard',
                }
            }
        ]
    },

    // 系统管理路由
    {
        path:"/system",
        component: Layout,
        name:'system',
        meta:{
            title:'系统管理',
            icon:'Setting',
            roles:['sys:manage'],
        },
        children:[
            {
                path:"/userList",
                // component:"/system/User/UserList", 原来的路径
                component: () => import('@/views/system/User/UserList.vue'), //现在指定到一个具体页面
                name:'userList',
                meta:{
                    title:'用户管理',
                    icon:'UserFilled',
                    roles:['sys:user'],
                },
            },
            {
                path:"/roleList",
                // component:"/system/Role/RoleList",
                component: () => import('@/views/system/Role/RoleList.vue'), //现在指定到一个具体页面
                name:'roleList',
                meta:{
                    title:'角色管理',
                    icon:'Wallet',
                    roles:['sys:role'],
                }
            },
            {
                path:"/menuList",
                // component:"/system/Menu/MenuList",
                component: () => import('@/views/system/Menu/MenuList.vue'), //现在指定到一个具体页面
                name:'menuList',
                meta:{
                    title:'菜单管理',
                    icon:'Menu',
                    roles:['sys:menu'],
                },
            }
        ]
    },




    // 商品管理路由
    {
        path:"/goodsRoot",
        component: Layout,
        name:'goodsRoot',
        meta:{
            title:'商品管理',
            icon:'Grid',
            roles:['sys:goodsRoot'],
        },
        children:[
            {
                path:"/category",
                // component:"/category/CategoryList",
                component: () => import('@/views/category/CategoryList.vue'), //现在指定到一个具体页面
                name:'category',
                meta:{
                    title:'物资类型',
                    icon:'UserFilled',
                    roles:['sys:category'],
                },
            },
            {
                path:"/goodsList",
                // component:"/goods/GoodsList",
                component: () => import('@/views/goods/GoodsList.vue'), //现在指定到一个具体页面
                name:'goodsList',
                meta:{
                    title:'商品信息',
                    icon:'Wallet',
                    roles:['sys:goodsList'],
                }
            }
        ]
    }

]

const router = createRouter({
    history: createWebHistory(),
    routes
})

export default router